package com.example.mobwe_project;

import java.io.File;

import android.app.Activity;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;

public class FullImageActivity extends Activity{
	 @Override
	    public void onCreate(Bundle savedInstanceState) {
	        super.onCreate(savedInstanceState);
	        setContentView(R.layout.full_image);
	        Button image=(Button)findViewById(R.id.button1);
			Button open=(Button)findViewById(R.id.button2);
			
			open.setOnClickListener(new OnClickListener() {
				
				@Override
				public void onClick(View v) {
				openNewActivity();
					
				}
			});
	        
			image.setOnClickListener(new OnClickListener() 
			{
				
				@Override
				public void onClick(View v) {
					goBack();
				}
			});
	 
	        // get intent data
	        Intent i = getIntent();
	 
	        // Selected image id
	        int position = i.getExtras().getInt("id");
	        ImageAdapter imageAdapter = new ImageAdapter(this);
	        
	        Ebook ebook = imageAdapter.getEbooks().get(position);
	        AppFolder app = new AppFolder();
	        File file = new File( app.getFolder() + "/" + ebook.getPreview() );
	 
	        ImageView imageView = (ImageView) findViewById(R.id.full_image_view);
	        //imageView.setImageResource(imageAdapter.getEbooks().get(position));
	        imageView.setImageDrawable(Drawable.createFromPath(file.getAbsolutePath()));
	 }

	protected void openNewActivity() {
	Intent open=new Intent(this,BookPresentation.class);
		startActivity(open);	
	
	}

	protected void goBack() {
	Intent back=new Intent(this,MenuActivity.class);
	startActivity(back);
		
	}

}
